import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/index/index.vue'
import Home from '../views/index/Home/home.vue'
import Utils from '../utils/util'
Vue.use(VueRouter)

const routes = [
  //account
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/account/login')
  },
  // ykf router
  {
    path:'/xinren',
    name:'xinren',
    component:()=>import('@/views/index/xinren/xinren')
  },
  {
    path:'/vipcenter',
    name:'vipcenter',
    component:()=>import(/* webpackChunkName: "movies" */ '@/views/index/Vip/Vipcenter')
  },
  {
    path:'/kaitongvip',
    component:()=>import('@/views/index/Vip/kaitongvip')
  },
  {
    path:'/special',
    name:'special',
    component:()=>import(/* webpackChunkName: "movies" */ '@/views/index/Special/Special')
  },
  {
    path:'/jingxuan',
    name:'jingxuan',
    component:()=>import(/* webpackChunkName: "movies" */ '@/views/index/Jingxuan/Jingxuan')
  },
  {
    path:'/lingquan',
    name:'lingquan',
    component:()=>import(/* webpackChunkName: "movies" */ '@/views/index/Lingquan/Lingquan')
  },
  {
    path:'/qiandao',
    name:'qiandao',
    component:()=>import(/* webpackChunkName: "movies" */ '@/views/index/Qiandao/Qiandao')
  },
  {
    path:'/search',
    name:'search',
    component:()=>import(/* webpackChunkName: "movies" */ '@/components/Search')
  },
 /*  {
    path: '/',
    redirect: '/index'
  }, */
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/index',
    name: 'index',
    redirect:'/index/home',
    component: Index,
    children: [
      {
        path: 'home',
        name: 'home',
        component: Home
      },
      {
        path: 'classification',
        name: 'classification',
        component: () => import('@/views/classification/classification')
      },
      {
        path: 'cart',
        name: 'cart',
        component: () => import('@/views/cart/index')
      },
      {
        path: 'news',
        name: 'news',
        component: () => import('@/views/news/index')
      },
      {
        path: 'mine',
        name: 'mine',
        component: () => import('@/views/mine/mine')
      }
    ]
  },
  
  {
    path: '/order',
    name: 'order',
    component: () => import(/* webpackChunkName: "movies" */ '@/views/mine/order/index')
  },
  {
    path: '/ShopList',
    name: 'ShopList',
    component: () => import(/* webpackChunkName: "movies" */ '@/views/shopList/ShopList')
  },
  {
    path: '/Details',
    name: 'Details',
    component: () => import(/* webpackChunkName: "movies" */ '@/views/details/Details')
  },
  {
    path: '/Evaluate',
    name: 'Evaluate',
    component: () => import(/* webpackChunkName: "movies" */ '@/views/details/Evaluate')
  },
  {
    path: '/NewAddress',
    name: 'NewAddress',
    component: () => import(/* webpackChunkName: "movies" */ '@/components/NewAddress')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
// router.beforeEach((to,from,next)=>{
//   let token = Utils.getLocalStorage('token')
//   let appid = Utils.getSessionStroage('appid')
//   if(token==appid&&token!=undefined&&appid!=undefined){
//     next()
//   }else{
//     if(to.name=='login'){
//       next()
//     }else{
//       router.push({ path: '/login'})
//     }
//   }
//   next()
// })

export default router
